home *** CD-ROM | disk | FTP | other *** search
/ Champak Vol K-12 / Vol K-12.iso / interfac / it.dig / scripts / FListBoxSymbol.as < prev    next >
Text File  |  2012-08-27  |  5KB  |  161 lines

  1. function FListBoxClass()
  2. {
  3.    this.itemSymbol = "FListItemSymbol";
  4.    this.init();
  5.    this.permaScrollBar = true;
  6.    var _loc2_ = 0;
  7.    while(_loc2_ < this.labels.length)
  8.    {
  9.       this.addItem(this.labels[_loc2_],this.data[_loc2_]);
  10.       _loc2_ = _loc2_ + 1;
  11.    }
  12.    this.boundingBox_mc.gotoAndStop(1);
  13.    this.width = this._width;
  14.    this.height = this._height;
  15.    this._yscale = this._xscale = 100;
  16.    this.setSize(this.width,this.height);
  17.    if(this.changeHandler.length > 0)
  18.    {
  19.       this.setChangeHandler(this.changeHandler);
  20.    }
  21. }
  22. FListBoxClass.prototype = new FScrollSelectListClass();
  23. Object.registerClass("FListBoxSymbol",FListBoxClass);
  24. FListBoxClass.prototype.getSelectedIndices = function()
  25. {
  26.    var _loc2_ = new Array();
  27.    for(var _loc3_ in this.selected)
  28.    {
  29.       _loc2_.push(this.selected[_loc3_].sIndex);
  30.    }
  31.    return _loc2_.length <= 0 ? undefined : _loc2_;
  32. };
  33. FListBoxClass.prototype.getSelectedItems = function()
  34. {
  35.    var _loc3_ = this.getSelectedIndices();
  36.    var _loc4_ = new Array();
  37.    var _loc2_ = 0;
  38.    while(_loc2_ < _loc3_.length)
  39.    {
  40.       _loc4_.push(this.getItemAt(_loc3_[_loc2_]));
  41.       _loc2_ = _loc2_ + 1;
  42.    }
  43.    return _loc4_.length <= 0 ? undefined : _loc4_;
  44. };
  45. FListBoxClass.prototype.getSelectMultiple = function()
  46. {
  47.    return this.selectMultiple;
  48. };
  49. FListBoxClass.prototype.getRowCount = function()
  50. {
  51.    return this.numDisplayed;
  52. };
  53. FListBoxClass.prototype.setSelectedIndices = function(indexArray)
  54. {
  55.    this.clearSelected();
  56.    var _loc2_ = 0;
  57.    while(_loc2_ < indexArray.length)
  58.    {
  59.       this.selectItem(indexArray[_loc2_],true);
  60.       _loc2_ = _loc2_ + 1;
  61.    }
  62.    this.updateControl();
  63. };
  64. FListBoxClass.prototype.setSelectMultiple = function(flag)
  65. {
  66.    this.selectMultiple = flag;
  67. };
  68. FListBoxClass.prototype.setRowCount = function(count)
  69. {
  70.    var _loc2_ = count * (this.itmHgt - 2) + 2;
  71.    this.setSize(this.width,_loc2_);
  72. };
  73. FListBoxClass.prototype.setWidth = function(wdt)
  74. {
  75.    this.setSize(wdt,this.height);
  76. };
  77. FListBoxClass.prototype.setSize = function(w, h)
  78. {
  79.    if(!this.enable)
  80.    {
  81.       return undefined;
  82.    }
  83.    w = Math.max(w,20);
  84.    h = Math.max(h,40);
  85.    this.container_mc.removeMovieClip();
  86.    this.container_mc = this.createEmptyMovieClip("container",3);
  87.    this.measureItmHgt();
  88.    this.numDisplayed = Math.floor(h / (this.itmHgt - 2));
  89.    this.height = this.numDisplayed * (this.itmHgt - 2) + 2;
  90.    super.setSize(w,this.height);
  91. };
  92. FListBoxClass.prototype.removeItemAt = function(index)
  93. {
  94.    this.selectHolder = this.getSelectedIndices();
  95.    return super.removeItemAt(index);
  96. };
  97. FListBoxClass.prototype.selectionHandler = function(itemNum)
  98. {
  99.    if(this.clickFilter)
  100.    {
  101.       var _loc3_ = this.topDisplayed + itemNum;
  102.       if(this.getItemAt(_loc3_) == undefined)
  103.       {
  104.          this.changeFlag = false;
  105.          return undefined;
  106.       }
  107.       this.changeFlag = true;
  108.       if(!this.selectMultiple && !Key.isDown(17) || !Key.isDown(16) && !Key.isDown(17))
  109.       {
  110.          this.clearSelected();
  111.          this.selectItem(_loc3_,true);
  112.          this.lastSelected = _loc3_;
  113.          this.container_mc["fListItem" + itemNum + "_mc"].drawItem(this.getItemAt(_loc3_),this.isSelected(_loc3_));
  114.       }
  115.       else if(Key.isDown(16) && this.selectMultiple)
  116.       {
  117.          if(this.lastSelected == -1)
  118.          {
  119.             this.lastSelected = _loc3_;
  120.          }
  121.          var _loc4_ = this.lastSelected >= _loc3_ ? -1 : 1;
  122.          this.clearSelected();
  123.          var _loc2_ = this.lastSelected;
  124.          while(_loc2_ != _loc3_)
  125.          {
  126.             this.selectItem(_loc2_,true);
  127.             if(_loc2_ >= this.topDisplayed && _loc2_ < this.topDisplayed + this.numDisplayed)
  128.             {
  129.                this.container_mc["fListItem" + (_loc2_ - this.topDisplayed) + "_mc"].drawItem(this.getItemAt(_loc2_),this.isSelected(_loc2_));
  130.             }
  131.             _loc2_ += _loc4_;
  132.          }
  133.          this.selectItem(_loc3_,true);
  134.          this.container_mc["fListItem" + (_loc3_ - this.topDisplayed) + "_mc"].drawItem(this.getItemAt(_loc3_),this.isSelected(_loc3_));
  135.       }
  136.       else if(key.isDown(17))
  137.       {
  138.          var _loc6_ = this.isSelected(_loc3_);
  139.          if(!this.selectMultiple)
  140.          {
  141.             this.clearSelected();
  142.          }
  143.          if(!(!this.selectMultiple && _loc6_))
  144.          {
  145.             this.selectItem(_loc3_,!_loc6_);
  146.             this.container_mc["fListItem" + itemNum + "_mc"].drawItem(this.getItemAt(this.topDisplayed + itemNum),this.isSelected(this.topDisplayed + itemNum));
  147.          }
  148.          this.lastSelected = _loc3_;
  149.       }
  150.    }
  151.    else
  152.    {
  153.       this.clickFilter = true;
  154.    }
  155. };
  156. FListBoxClass.prototype.moveSelBy = function(itemNum)
  157. {
  158.    super.moveSelBy(itemNum);
  159.    this.releaseHandler();
  160. };
  161.